<template>
<view class="update-cq-view">
	<view class="item">
		<view class="title">
			情况简介
		</view>
		<u-input
			v-model="dataInfo.synopsis"
			type="textarea" maxlength="9999999" height="200"
			:border="true" placeholder="请输入进度简介"/>
	</view>
	<view class="item">
		<view class="title">
			进度时间
		</view>
		<SelectDateBt
			v-model="dataInfo.thisDate"
			title="请选择进度时间"
			:params="{
				year: true,
				month: true,
				day: true,
				hour: false,
				minute: false,
				second: false,
			}">
		</SelectDateBt>
	</view>
	<view class="item">
		<view class="title">
			进度比例
		</view>
		<view class="slider-container">
			<u-slider 
				v-model="dataInfo.thisScheduleRate" 
				min="0" max="100" height="15">
			</u-slider>
			{{dataInfo.thisScheduleRate}}%
		</view>
	</view>
	<view class="item">
		<view class="title">
			进度情况
		</view>
		<u-input
			v-model="dataInfo.thisSchedule"
			type="textarea" maxlength="9999999"
			height="200"
			:border="true" placeholder="请输入进度情况"/>
	</view>
	<view class="bottom-container">
		<u-button @click="onUpdate" type="primary">确定修改</u-button>
		<u-button @click="onCancel" type="error">取消</u-button>
	</view>
	<u-top-tips ref="uTips"></u-top-tips>
</view>
</template>

<script>
/*
 修改拆迁情况页面
 */
import SelectDateBt from '@/components/public/SelectDateBt';
import SelectTypeCp from "@/components/summery/SelectType";
import {deleteSummary,getDemolition,saveDemolition} from "@/common/Api";
export default {
	components: {
		SelectDateBt,
		SelectTypeCp,
	},
	data() {
		this.projectId;  //项目id
		return {
			dataInfo:{},
		}
	},
	onLoad(options){
		this.projectId = options?options.projectId:undefined;  //页面传参
		if(this.projectId){
			this.getDataInfo(this.projectId);
		}
	},
	methods: {
		getDataInfo(projectId){  //根据projectId获取数据详情
			getDemolition({
				projectId:projectId,
			}).then(res=>{
				let data = res.data.data;
				this.dataInfo = data || {};
			});
		},
		onUpdate(){  //修改数据
			uni.showLoading({
				title: '加载中'
			});
			saveDemolition(this.dataInfo).then(res=>{
				let data = res.data.data;
				this.$refs.uTips.show({
					title: data,
					type: 'success',
					duration: '700',
				});
				setTimeout(()=>{  //回退
					uni.navigateBack();
				},700);
			}).finally(()=>{
				uni.hideLoading();
			});
		},
		onCancel(){
			uni.navigateBack();
		},
	}
}
</script>

<style>
	page{
		background-color: #fff;
	}
</style>
<style lang="scss" scoped>
.update-cq-view {
	background-color: #fff;
	display: grid;
	grid-gap:20px;
	padding: 20px;
	box-sizing: border-box;
	>.item{
		display: grid;
		grid-gap:10px;
		>.title{
			font-size: 16px;
			font-weight: bold;
		}
		>.slider-container{
			display: grid;
			grid-template-columns: 1fr max-content;
			align-items: center;
			grid-gap: 15px;
		}
	}
	>.bottom-container{
		display: grid;
		grid-template-columns: 1fr 1fr;
		grid-gap: 15px;
		margin-top: 30px;
	}
}
</style>
